var util = require('util');
/**
 * @fileOverview Stuff.
 * 
 * @author jmanero
 * 
 */

/** @ignore */
exports.callback = function(req, res) {
	switch (req.params.action) {
	case 'reset':
		model.Message.remove({}, function(e) {
			model.Message.error(e);
			res.redirect('https://' + req.header('X-Request-Host') + '/log');
		});
		model.Message.log('Info', 'Clearing Logs');
		break;
	default:
		model.Message.findOne({_id : req.params.action}, function(e, entry) {
			model.Message.error(e);
			if(entry) {
				res.render('logEntry.jade', {
					pageTitle : 'Log Entry',
					entry : entry,
					pretty : true
				});
			} else
				res.redirect('https://' + req.header('X-Request-Host') + '/log');
		});
	}
};

/** @ignore */
exports.path = '/log/:action';

/** @ignore */
exports.method = 'get';
